package cn.yunhe.action;

import cn.yunhe.model.User;
import cn.yunhe.services.UserServices;
import cn.yunhe.util.BaseAction;

/**
 * 
 * @author Administrator
 *
 */
public class UserAction extends BaseAction{

	private String username;
	private String userpass;
	private User user;
	private UserServices us = new UserServices();
	/**
	 * 登录
	 * @return
	 */
	public String login(){
		user = us.login(username, userpass);
		if(user!=null){
			getSession().setAttribute("user", user);
			return SUCCESS;
		}
		return ERROR;
	}
	/**
	 * 注册
	 * @return
	 */
	public String regist(){
		if(us.regist(user)){
			return SUCCESS;
		}
		return ERROR;
	}
	
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public UserServices getUs() {
		return us;
	}
	public void setUs(UserServices us) {
		this.us = us;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getUserpass() {
		return userpass;
	}
	public void setUserpass(String userpass) {
		this.userpass = userpass;
	}
	
}
